package us.pinguo.imageloader;

import android.app.Application;
import android.os.Environment;

import java.io.File;

import us.pinguo.loader.PinguoImageLoader;

public class PinguoApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        initImageLoader();
    }

    private void initImageLoader() {
        String path="";
        if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
            path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/pinguo/cache/";
        } else {
            ///data/data/us.pinguo.imageloader.demo/cache
            path = getApplicationContext().getCacheDir().getAbsolutePath();
        }
        File dir = new File(path);
        if (!dir.isDirectory() || !dir.exists()) {
            dir.mkdirs();
        }
        PinguoImageLoader.init(this, path);
    }
}
